{include file="public/header" /}


 
    
    
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" action="__APP__/admin/User/index" method="get">
          <input class="layui-input" placeholder="开始时间" name="start" id="start">
          <input class="layui-input" placeholder="截止时间" name="end" id="end">
          <input type="text" name="username" id="username"  placeholder="用户名" autocomplete="off" class="layui-input">
          <input type="text" name="phone_s" id="phone_s" placeholder="手机号" autocomplete="off" class="layui-input">

          <button class="layui-btn"  type="submit"><i class="layui-icon">&#xe615;</i></button>
        </form>

        <script type="text/javascript">
            $("#phone_s").val("{$phone_s}");
            $("#username").val("{$username}");
            $("#start").val("{$start}");
            $("#end").val("{$end}");
        </script>

      </div>
    
      <table class="layui-table">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>用户名</th>
            <th>手机号</th>
            <th>设备型号</th>
            <th>地址</th>
            <th>加入时间</th>
            <th>状态</th>
            <th>操作</th>
        </thead>
        <tbody>
          {foreach name="lists" item="v" key="k" }
            <tr>
              <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
              </td>
              <td>{$v.id}</td>
              <td>{$v.username}</td>
              <td>{$v.phone}</td>
              <td>{$v.device_type}</td>
              <td>{$v.area}</td>
              <td>{$v.ctime}</td>
              <td class="td-status">
                {if condition=" $v.status == '1' "}
                <span class="layui-badge-dot layui-bg-green"></span>
                <span class="layui-badge-rim">正常</span>
                {else if condition=" $v.status == '2' " /}
                <span class="layui-badge-dot"></span>
                <span class="layui-badge-rim">冻结</span>
                {/if}
              </td>
              <td class="td-manage">
                <a onclick="member_stop(this,'10001')" href="javascript:;"  title="启用">
                  <i class="layui-icon">&#xe601;</i>
                </a>
                <a title="编辑"  onclick="x_admin_show('编辑','admin-edit.html')" href="javascript:;">
                  <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
                  <i class="layui-icon">&#xe640;</i>
                </a>
              </td>
            </tr>
          {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div>
        {$page}
        </div>
      </div>

    </div>



<!-- --------------------js--------------------- -->

<script>
//日期选择
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //执行一个laydate实例
  laydate.render({
    elem: '#start' //指定元素
    ,type:'datetime'
  });

  //执行一个laydate实例
  laydate.render({
    elem: '#end' //指定元素
    ,type:'datetime'
  });
});


  //模态窗
  function model_add (type,id,name,pid,controller,action,icon,rank,status) {
    if(type == 1){
      var txt = '添加'; 
    }else{
      var txt = '编辑'; 

    }
    layui.use(['layer','form'], function() {
      var form = layui.form;    //渲染
      var layer = layui.layer; //唤起模态窗

      layer.open({
        type: 1,
        title: txt,
        area: ['500px', '500px'] ,
        shadeClose: true,
        content: $('#box').html()
      })
      $('#id').val(id);
      $('#name').val(name);
      $('#pid').val(pid);
      $('#controller').val(controller);
      $('#action').val(action);
      // $('#icon').val('<i class="iconfont">'+icon+'</i>');
      $('#rank').val(rank);
      $(":radio[name='status'][value="+status+"]").attr("checked","checked");  

      form.render();//渲染
    })
  }


//确定-提交
function sub(){

  var name = $('#name').val();
  if(name == ''){
      layer.msg('菜单名不能为空',{
        time:900  ,           //时间
      });
      return false;
  }
  
  $.ajax({
      type:"get",
      url:"__APP__/admin/Menu/add_edit",
      data:$(".layui-form").serialize(),

      success:function(data){
        // alert(data);
        returnInfo(data);

      }        
  })//ajax结束
}

   /*用户-停用*/
  function member_stop(obj,id){
      layer.confirm('确认要停用吗？',function(index){

          if($(obj).attr('title')=='启用'){

            //发异步把用户状态进行更改
            $(obj).attr('title','停用')
            $(obj).find('i').html('&#xe62f;');

            $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
            layer.msg('已停用!',{icon: 5,time:1000});

          }else{
            $(obj).attr('title','启用')
            $(obj).find('i').html('&#xe601;');

            $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
            layer.msg('已启用!',{icon: 5,time:1000});
          }
          
      });
  }

  /*用户-删除*/
  function member_del(obj,id){
      layer.confirm('确认要删除吗？',function(index){
          //发异步删除数据
          $(obj).parents("tr").remove();
          layer.msg('已删除!',{icon:1,time:1000});
      });
  }



  function delAll (argument) {

    var data = tableCheck.getData();

    layer.confirm('确认要删除吗？'+data,function(index){
        //捉到所有被选中的，发异步进行删除
        layer.msg('删除成功', {icon: 1});
        $(".layui-form-checked").not('.header').parents('tr').remove();
    });
  }
</script>


{include file="public/footer" /}


<!-- --------------------弹窗--------------------- -->

<script id="box">
        <style type="text/css">
        .layui-word-aux{
          font-size:12px;
        }
        </style>
        <form class="layui-form">
        <input type="hidden" id="id" name="id" value='' class="layui-input">
          <div class="layui-form-item" style="margin-top:20px">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>菜单名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="name" name="name"  class="layui-input">
              </div>
          </div>

          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                  <span class="x-red">*</span>选择分级
              </label>
              <div class="layui-input-inline">
                <select name="pid" id="pid" lay-verify="required">
                  
                  <option value="0">--顶级菜单--</option>
                  {foreach name="fenji_list" item="v" key="k" }
                  <option value="{$v.id}">{$v.name}</option>
                  {/foreach}
                
                </select>
              </div>
              <div class="layui-form-mid layui-word-aux">
                  控制器为空是分级选项
              </div>
          </div>

          <div class="layui-form-item">
              <label class="layui-form-label">
                  控制器名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="controller" name="controller" required="" 
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  非跳转不填
              </div>
          </div>

          <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">
                  方法名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="action" name="action" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  同上(显示初始页固定为index)
              </div>
          </div>


          <div class="layui-form-item">
              <label class="layui-form-label">
                icon 
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="icon" name="icon"  class="layui-input" >
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <a target="view_window" href="__APP__/admin/Admin/icon.html">查看字体图标</a>
              </div>
          </div>

          <div class="layui-form-item">
              <label  class="layui-form-label">
                  排序
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="rank" name="rank"  class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  数字越大越靠前
              </div>
          </div>

          

          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                是否显示
              </label>
              
              <div class="layui-input-block">
                <input type="radio" name="status" id='status' value="1" title="显示" checked="">
                <input type="radio" name="status" id='status' value="0" title="不显示">
                
              </div>
          </div>
          <hr/>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>

              <a  class="layui-btn" onclick="sub()">
                  提交
              </a>
          </div>
      </form>
</script>